package com.ysk.test.demo.web;

import com.ysk.test.demo.pojo.Role;
import com.ysk.test.demo.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    @RequestMapping("/findAll")
    public List<Role> findAll(){
        return roleService.findAll();
    }

    @RequestMapping("/save/{rName}")
    public int insert(@PathVariable("rName") String rName){
        return roleService.save(rName);
    }

    @RequestMapping("/update/{rId}/{rName}")
    public int update(@PathVariable("rId") Integer rId, @PathVariable("rName") String rName){
        return roleService.update(rId,rName);
    }

    @RequestMapping("/delete/{rId}")
    public int delete(@PathVariable("rId") Integer rId){
        return roleService.delete(rId);
    }
}
